<template>
	<div class="login-container">
		<div class="login-logo">
			<span style="font-weight: bold">大地生态erp系统欢迎您！</span>
			<span style="font-size: 13px; margin-top: 10px">{{ time.year }} 年 {{ time.mdq }} {{ time.hm }} {{ time.s }}</span>
		</div>
		<div class="login-content" :class="{ 'login-content-mobile': tabsActiveName === 'mobile' }">
			<div class="login-content-main">
				<h4 class="login-content-title">登 录</h4>
				<el-tabs v-model="tabsActiveName" @tab-click="onTabsClick">
					<!-- :label="$t('message.label.one1')" -->
					<el-tab-pane name="account" :disabled="tabsActiveName === 'account'">
						<transition name="el-zoom-in-center">
							<Account v-show="isTabPaneShow" />
						</transition>
					</el-tab-pane>
					<!-- <el-tab-pane :label="$t('message.label.two2')" name="mobile" :disabled="tabsActiveName === 'mobile'">
						<transition name="el-zoom-in-center">
							<Mobile v-show="!isTabPaneShow" />
						</transition>
					</el-tab-pane> -->
				</el-tabs>
				<!-- <div class="mt10">
					<el-button type="text" size="small">{{ $t('message.link.one3') }}</el-button>
					<el-button type="text" size="small">关于我们</el-button>
					<el-button type="text" size="small">{{ $t('message.link.two4') }}</el-button>
				</div> -->
			</div>
		</div>
		<div class="login-copyright">
			<div class="mb5 login-copyright-company">大地生态erp系统</div>
			<div class="login-copyright-msg">Copyright © 2021-2021 重庆大地生态环境科技集团股份有限公司版权所有</div>
		</div>
	</div>
</template>

<script lang="ts">
import { toRefs, reactive, computed, defineComponent, onMounted, onUnmounted } from 'vue';
import Account from '/@/views/login/component/account.vue';
import Mobile from '/@/views/login/component/mobile.vue';
import { useStore } from '/@/store/index';
import { formatDate } from '/@/utils/formatTime'; //导入时间处理方法
export default defineComponent({
	name: 'login',
	components: { Account, Mobile },
	setup() {
		const store = useStore();
		const state: any = reactive({
			tabsActiveName: 'account',
			isTabPaneShow: true,
			time: {
				year: '',
				hm: '',
				s: '',
				mdq: '',
			},
			setIntervalTime: 0,
		});
		// 获取布局配置信息
		const getThemeConfig = computed(() => {
			return store.state.themeConfig.themeConfig;
		});
		// 切换密码、手机登录
		const onTabsClick = () => {
			state.isTabPaneShow = !state.isTabPaneShow;
		};
		// 时间初始化
		const initTime = () => {
			state.time.year = formatDate(new Date(), 'YYYY');
			state.time.hm = formatDate(new Date(), 'HH:MM');
			state.time.s = formatDate(new Date(), 'SS');
			state.time.mdq = formatDate(new Date(), 'mm月dd日，WWW');
		};
		// 时间初始化定时器
		const initSetTime = () => {
			initTime();
			state.setIntervalTime = window.setInterval(() => {
				initTime();
			}, 1000);
		};
		// 页面加载时
		onMounted(() => {
			initSetTime();
		});
		// 页面卸载时
		onUnmounted(() => {
			window.clearInterval(state.setIntervalTime);
		});

		return {
			onTabsClick,
			getThemeConfig,
			...toRefs(state),
		};
	},
});
</script>

<style scoped lang="scss">
.login-container {
	width: 100%;
	height: 100%;
	background: url('./../../../public/bg-login.png') no-repeat;
	background-size: 100% 100%;
	.login-logo {
		position: absolute;
		top: 30px;
		left: 50%;
		height: 50px;
		display: flex;
		align-items: flex-start;
		justify-content: center;
		flex-direction: column;
		font-size: 20px;
		color: var(--color-primary); // 获取全局颜色更改
		letter-spacing: 2px;
		width: 90%;
		transform: translateX(-50%);
	}
	.login-content {
		width: 500px;
		padding: 20px;
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%) translate3d(0, 0, 0);
		background-color: rgba(255, 255, 255, 0.99);
		border: 5px solid var(--color-primary-light-8);
		border-radius: 4px;
		transition: height 0.2s linear;
		height: 480px;
		overflow: hidden;
		z-index: 1;
		.login-content-main {
			margin: 0 auto;
			width: 80%;
			.login-content-title {
				// color: #333;
				color: var(--color-primary); // 获取全局颜色更改
				font-weight: 500;
				font-size: 22px;
				text-align: center;
				letter-spacing: 4px;
				margin: 15px 0 30px;
				white-space: nowrap;
			}
		}
	}
	.login-content-mobile {
		height: 418px;
	}
	.login-copyright {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 30px;
		text-align: center;
		color: white;
		font-size: 12px;
		opacity: 0.8;
		.login-copyright-company {
			white-space: nowrap;
		}
		.login-copyright-msg {
			@extend .login-copyright-company;
		}
	}
}
</style>
